<template>
  <div class="app-container">
    <warehouseInOverviewDelRecordVue ref="openWarehouseInOverviewDelRecord" @refresh="refresh"></warehouseInOverviewDelRecordVue>
    <el-form @submit.native.prevent :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px" :label-position="labelPosition">
      <el-form-item label="单号" prop="pzbh">
        <el-input
          v-model="queryParams.pzbh"
          placeholder="请输入单号"
          clearable
          @keyup.enter.native="enterClick"
        />
      </el-form-item>
      <el-form-item label="外部单号" prop="wbdh">
        <el-input
          v-model="queryParams.wbdh"
          placeholder="请输入外部单号"
          clearable
          @keyup.enter.native="enterClick"
        />
      </el-form-item>
      <el-form-item label="客户" prop="khmc">
        <el-input
          v-model="queryParams.khmc"
          placeholder="请输入客户"
          clearable
          @keyup.enter.native="enterClick"
        />
      </el-form-item>
      <el-form-item label="物品规格" prop="spzs">
        <el-input
          v-model="queryParams.spzs"
          placeholder="请输入物品规格"
          clearable
          @keyup.enter.native="enterClick"
        />
      </el-form-item>
      <el-form-item label="品牌" prop="spcd">
        <el-input
          v-model="queryParams.spcd"
          placeholder="请输入品牌"
          clearable
          @keyup.enter.native="enterClick"
        />
      </el-form-item>
      <el-form-item label="柜号/批号" prop="spgh">
        <el-input
          v-model="queryParams.spgh"
          placeholder="请输入柜号/批号"
          clearable
          @keyup.enter.native="enterClick"
        />
      </el-form-item>
      <el-form-item label="仓库" prop="status">
        <el-select
            v-model="queryParams.spckmc"
            placeholder="请选择"
            clearable
            style="width: 240px"
            @change="changeWarehouse"
            :loading="selectWarehouse11Loading"
        >
            <el-option
                v-for="item in warehouseList"
                :key="item.spckid"
                :label="item.spckmc"
                :value="item.spckid"
            />
        </el-select>
      </el-form-item>
      <el-form-item label="车牌" prop="dzzy6">
        <el-input
          v-model="queryParams.dzzy6"
          placeholder="请输入车牌"
          clearable
          @keyup.enter.native="enterClick"
        />
      </el-form-item>
       <el-form-item label="审核状态" prop="shzt">
        <el-select
            v-model="queryParams.shzt"
            placeholder="请选择"
            clearable
            style="width: 240px"
            @change="changeWarehouse"
        >
            <el-option
                v-for="item in auditState"
                :key="item.value"
                :label="item.label"
                :value="item.value"
            />
        </el-select>
      </el-form-item>
       <el-form-item label="条码" prop="sptm">
        <el-input
          v-model="queryParams.sptm"
          placeholder="请输入条码"
          clearable
          @keyup.enter.native="enterClick"
        />
      </el-form-item>
      <el-form-item label="业务日期" prop="warehouseInDate">
        <el-date-picker
          v-model="warehouseInDate"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="warehouseInDateChange()">
        </el-date-picker>
      </el-form-item>
      <el-form-item >
        <el-checkbox v-model="queryParams.jqcz" label="精确搜索" true-label="1" @change="getList"></el-checkbox>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
      </el-form-item>
    </el-form>
     <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button  type="primary" plain size="mini" @click="deleteRecord()" v-hasPermi="['zhcloud:hwrc:list']">已删除记录</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button type="primary" plain size="mini" @click="handleExport"  v-hasPermi="['zhcloud:hwrc:export']">导出为Excel</el-button>
        </el-col>
    </el-row>
    <el-table
      :data="warehouseInList"
      :show-summary="false"
      ref="warehouseInTable"
    >
      <af-table-column prop="pzbh" label="单据号"  fixed="left"></af-table-column>
      <af-table-column prop="wbdh" label="外部单号" ></af-table-column>
      <af-table-column prop="allName" label="客户" ></af-table-column>
      <af-table-column prop="spzs" label="物品规格" ></af-table-column>
      <af-table-column prop="spbh" label="批号" ></af-table-column>
      <af-table-column prop="spgh" label="柜号" ></af-table-column>
      <af-table-column prop="spcd" label="品牌" ></af-table-column>
      <af-table-column prop="spjs" label="件数" ></af-table-column>
      <af-table-column prop="spjsl" label="单重(KG)" ></af-table-column>
      <af-table-column prop="spsl" label="重量(吨)" ></af-table-column>
      <af-table-column prop="spckmc" label="仓库" ></af-table-column>
      <af-table-column prop="ckcw" label="仓位" ></af-table-column>
      <af-table-column prop="ssrqida" label="业务日期" ></af-table-column>
      <af-table-column prop="iszxf" label="装卸费" ></af-table-column>
      <af-table-column prop="iszyl" label="作业量" ></af-table-column>
      <af-table-column prop="prrq" label="创建时间" ></af-table-column>
      <af-table-column prop="rsopmc" label="创建人" ></af-table-column>
      <af-table-column prop="dzbz" label="备注"  width="150" :show-overflow-tooltip="true"></af-table-column>
      <af-table-column prop="ssrqid" label="入仓日期" ></af-table-column>
      <af-table-column prop="spbz" label="条码备注" ></af-table-column>
      <af-table-column prop="sptm" label="客户条码" ></af-table-column>
      <af-table-column prop="sptmc" label="仓库条码" ></af-table-column>
      <af-table-column prop="dzzy6" label="车牌" ></af-table-column>
      <af-table-column prop="wpggA" label="纱支" ></af-table-column>
      <af-table-column prop="wpggB" label="工艺" ></af-table-column>
      <af-table-column prop="wpggC" label="工序" ></af-table-column>
      <af-table-column prop="wpggD" label="用途" ></af-table-column>
      <af-table-column prop="wpggE" label="产地" ></af-table-column>
      <af-table-column prop="wpggF" label="漂染性" ></af-table-column>
      <af-table-column prop="wpggG" label="生产日期" ></af-table-column>
      <af-table-column prop="wpggH" label="颜色" ></af-table-column>
    </el-table>
     <pagination
        v-show="total>0"
        :total="total"
        :page.sync="pageNum"
        :limit.sync="pageSize"
        @pagination="getList"
      />
  </div>

</template>

<script>
import { getWarehouseInOverview }  from "@/api/storage/commonGoods/warehouseIn";
import { selectWarehouse11 } from "@/api/storage/warehouse"
import warehouseInOverviewDelRecordVue from "./warehouseInOverviewDelRecord.vue";

export default {
  name: "WarehouseInOverview",
  components: { warehouseInOverviewDelRecordVue },
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      // 对齐方式
      labelPosition:"right",
      //表格加载
      loading: true,
      //仓库加载
      selectWarehouse11Loading:true,
      //审核状态
      auditState:[{
        value: "未审核",
        label:"未审核"
      },{
        value: "已审核",
        label:"已审核"
      }],
      warehouseInDate:'',
      // 查询参数
      queryParams: {
        dzzy6: "",
        isBa: "",
        jqcz: "",
        khmc: "",
        khpb: 0,
        pzbh: "",
        qycz: "",
        s1: "",
        s2: "",
        shopId: 0,
        shzt: "",
        spbh: "",
        spcd: "",
        spckidis: [],
        spckmc: "",
        spgh: "",
        spmc: "",
        sptm: "",
        spzs: "",
        wbdh: "",
        downloadType:"json"
      },
      //excel导出
       exportList: [],
      //获取仓位参数
      selectPositionQuery:{
         spckid:""
      },
      // 货物入仓列表
      warehouseInList: [],
      //仓库列表
      warehouseList:[],
      //页数
      pageSize: 10,
      //页码
      pageNum:1,
      // 总条数
      total: 0,
    };
  },
  beforeRouteEnter(to, from, next) {
    const query = to.query
    next(vm => {
      vm.queryParams.pzbh = query.pzbh
      vm.getList()
    })
  },
  created() {
    this.getWarehouse()
  },
  methods: {
    /**获取仓库 */
    getWarehouse() {
      this.selectWarehouse11Loading = true
      selectWarehouse11({}).then(response => {
        this.warehouseList = response.data
        this.selectWarehouse11Loading = false
      });
    },
    /** 查询货物入仓列表 */
    getList() {
      this.loading = true
      getWarehouseInOverview(this.queryParams, {pageNum:this.pageNum, pageSize:this.pageSize}).then(response => {
        this.warehouseInList = response.rows;
        this.total = response.total;
        this.loading = false
      });
    },

    /**选择仓库 */
    changeWarehouse(row) {
      this.selectPositionQuery.spckid = row
      this.getList()
    },

    /**选择审核状态 */
    changeWarehouseAuditState() {
      this.getList()
    },

     /**业务日期 */
    warehouseInDateChange() {
      this.queryParams.s1 = this.warehouseInDate[0]
      this.queryParams.s2 = this.warehouseInDate[1]
      this.getList()
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.pageNum = 1
      this.getList();
    },

    /** 删除记录*/
    deleteRecord() {
      this.$refs.openWarehouseInOverviewDelRecord.open()
    },

    /** 导出勾选数据*/
    handleExport() {
      this.download('/storage/hwrc/export', this.queryParams, `货物入仓总览_${new Date().getTime()}.xlsx`)
    },
     /**enter键触发 */
    enterClick(e) {
      this.getList()
    },

    /** 刷新数据*/
    refresh() {
      this.getList()
    },
    reset() {
      Object.assign(this.$data, this.$options.data())
    },
  }
};
</script>
